package c15IO;

import java.io.File;
import java.io.FilenameFilter;

public class 文件过滤器 {

	public static void main(String[] args) {
		File f = new File("G:/[temp]");
		String[] fns = f.list(new MyFilenameFilter());
		System.err.println(fns.length);
		for (String s : fns) {
			System.err.println(s);
		}
	}

}

class MyFilenameFilter implements FilenameFilter {

	@Override
	public boolean accept(File dir, String name) {
		//若文件以.jpg结尾或对应一个文件夹，该文件就符合过滤要求！
		return name.endsWith(".jpg") || new File(dir, name).isDirectory();
	}

}